#ifndef QUEUE_H
#define QUEUE_H

#include <stdint.h>
#include <visibility.h>
#include "NoCopy.h"

class Mutex;
class Semaphore;

class __EXPORT Queue : NoCopy {
public:
	Queue(uint32_t maxSize, uint32_t messageSize);
	~Queue();
	bool get(void *message, uint32_t timeout = ~0U);
	bool put(const void *message, uint32_t timeout = ~0U);
	void flush();
private:
	Queue();

	const uint32_t maxSize_;
	const uint32_t messageSize_;
	uint32_t head_;
	uint32_t tail_;
	uint8_t *buf_;
	Mutex *mutex_;
	Semaphore *getSemaphore_;
	Semaphore *putSemaphore_;
};

#endif
